﻿<script>
    var toolbar_zidian = [{
        text: '新增',
        iconCls: 'icon-add',
        handler: function () {
            $("#info-fenzu").textbox('setText', '');
            $("#info-xiangmu").textbox('setText', '');
            $("#zidian-edit").dialog('open');
            $("#ziDianID").val("");
        }
    }, '-', {
        text: '修改',
        iconCls: 'icon-edit',
        handler: function () {
            var curRow = $("#xinxi_zidian").datagrid('getSelected');
            if (curRow) {
                $("#ziDianID").val(curRow.id);
                $("#info-fenzu").textbox('setValue', curRow.fenzu);
                $("#info-xiangmu").textbox('setValue', curRow.xiangmu);
                $("#zidian-edit").dialog('open');
            }
            else {
                alert("请选择要修改的字典信息。");
            }
        }
    }, '-', {
        text: '删除',
        iconCls: 'icon-remove',
        handler: function () {
            $("#zidian-dlg").dialog('open');
        }
    }];

function DelZiDian() {
    var curRow = $("#xinxi_zidian").datagrid('getSelected');
    if (curRow) {
        $.post('handler/xinxi_zidian.ashx', { ziDianType: "3", ziDianID: curRow.id,uid:window.uid,kid:window.kid }, function(data, status) {
            if (data == "OK") {
                $("#zidian-dlg").dialog('close');
                $("#xinxi_zidian").datagrid('load');
                return;
            }
            if (data == "Failed") {
                alert("删除字典信息失败，请重试");
                $("#biaoduan-dlg").dialog('close');
                return;
            }
            alert(data);
            $("#biaoduan-dlg").dialog('close');
        });
    }
    else {
        alert("请选择要删除的字典信息。");
    }
}

        function submitZiDianForm() {
            var fenzu = $("#info-fenzu").textbox('getText');
            var xiangmu = $("#info-xiangmu").textbox('getText');
            var zidianid = $("#ziDianID").val();
            if (fenzu && xiangmu) {
                $.post("handler/xinxi_zidian.ashx", { uid: window.uid, kid: window.kid, ziDianID: zidianid, ziDianType:'2', fenzu: fenzu, xiangmu: xiangmu}, function (data, status) {
                    if (data == "OK") {
                        $("#zidian-edit").dialog('close');
                        $("#xinxi_zidian").datagrid('load');
                        return;
                    }
                    if (data == "Failed") {
                        alert("保存字典信息失败，请重试");
                        return;
                    }
                    alert(data);
                });
            }
            else {
                alert("信息不完整，请检查重试。");
            }
        }
        function clearZiDianForm() {
            $("#zidian-edit").dialog('close');
        }

        $("#xinxi_zidian").datagrid({ url: 'handler/xinxi_zidian.ashx', method: 'post', queryParams: { ziDianType: '1',uid:window.uid,kid:window.kid },  height: document.body.scrollHeight - 90, onSelect: function(index, row) { } });

</script>

<table id="xinxi_zidian" style="width: 100%" title="字典管理"
    data-options="border: false, singleSelect: true, collapsible: false, striped: true, toolbar: toolbar_zidian">
    <thead>
        <tr>
            <th data-options="field:'fenzu',width:200">
                分组名称
            </th>
            <th data-options="field:'xiangmu',width:150">
                项目名称
            </th>
            <th data-options="field:'id',hidden:true">
                编号
            </th>
        </tr>
    </thead>
</table>

<div id="zidian-edit" class="easyui-dialog" title="字典信息编辑" data-options="modal:true,closed:true,iconCls:'icon-edit',draggable:false,collapsible:false,minimizable:false,maximizable:false,resizable:false"
    style="width: 500px; height: 240px; padding: 10px;">
    <div style="width: 350px; margin: 0 auto;">
        <table cellpadding="5" style="font-size: 13px; margin: 0 auto; padding-top: 20px">
            <tr>
                <td>
                    分组:
                </td>
                <td>
                    <input class="easyui-textbox" type="text" id="info-fenzu" name="info-fenzu"
                        data-options="width:200"></input>
                </td>
            </tr>
            <tr>
                <td>
                    项目:
                </td>
                <td>
                    <input class="easyui-textbox" type="text" id="info-xiangmu" name="info-xiangmu"
                        data-options="width:200"></input>
                </td>
            </tr>
        </table>
        <input type="hidden" name="ziDianID" id="ziDianID" value="" />
        <div style="text-align: center; padding: 5px">
            <a href="javascript:void(0)" class="easyui-linkbutton" style="width: 75px" onclick="submitZiDianForm()"
                data-options="iconCls:'icon-ok'">保存</a> <a href="javascript:void(0)" class="easyui-linkbutton"
                    style="width: 75px" onclick="clearZiDianForm()" data-options="iconCls:'icon-cancel'">
                    关闭</a>
        </div>
    </div>
</div>

<div id="zidian-dlg" class="easyui-dialog" title="删除确认" style="width: 300px; height: 150px;
    padding: 10px" data-options="
				iconCls: 'icon-help',
				buttons: '#zidian-dlg-buttons',
				modal:true,
				closed:true
			">
    确定要删除该字典信息吗？
</div>
<div id="zidian-dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:DelZiDian();">
        确定</a> <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#zidian-dlg').dialog('close')">
            取消</a>
</div>